package cn.com.zetatech.hdjc.service.controller;

import cn.com.zetatech.hdjc.model.HdjcCar;
import cn.com.zetatech.hdjc.service.bo.HelloBo;
import cn.com.zetatech.hdjc.entity.Hello;
import cn.com.zetatech.hdjc.api.HelloService;
import cn.com.zetatech.hdjc.service.mapper.HdjcCarMapper;
import cn.com.zetatech.service.common.mvc.BaseBo;
import cn.com.zetatech.service.common.mvc.BaseController;
import org.apache.commons.lang.RandomStringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.logging.SimpleFormatter;

@RestController
@RequestMapping("hello")
public class HelloController {

    @Value("${spring.datasource.url}")
    private String test ;
    @Autowired
    private HelloBo helloBo;
    @Autowired
    private HdjcCarMapper hdjcCarMapper;

    @GetMapping("/insert{id}")
    public void insert(@PathVariable String id){
        HdjcCar hdjcCar = new HdjcCar();
        System.out.println(test);
        List<HdjcCar> all = hdjcCarMapper.getAll();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        String s = format.format(new Date());
        String s1 = RandomStringUtils.randomAlphabetic(16);
        hdjcCar.setId(s1);
        hdjcCar.setCarNumber("test1");
        hdjcCar.setCarName("test-QQ");
        Timestamp timestamp = new Timestamp(new Date().getTime());
        hdjcCar.setInsuranceTime(timestamp);
        hdjcCar.setInsuranceTime(new Date());
        System.out.println(s);
        System.out.println(timestamp);
        hdjcCar.setAnnualVerificationTime(timestamp);
        hdjcCar.setCarPrincipal("test-prin");
        hdjcCar.setInfo("test-info");
        hdjcCar.setState(1);
        hdjcCar.setCreateBy("test-by");
        hdjcCar.setCreateTime(new Date());
        hdjcCar.setDeleted(0);
        if (hdjcCarMapper != null)
            hdjcCarMapper.insert(hdjcCar);
        else
            System.out.println("error");
    }

}
